/******************************************************************************
 * (C) Copyright 2016 Atech-Automotive
 * FILE NAME:   
 * DESCRIPTION:
 * 
 * DATE BEGUN:   
 * BY:           
 * PRODUCT NAME:
 * APPLICATION:
 * TARGET H/W:
 * DOC REF:
 *****************************************************************************
 */

#ifndef _DRV_SCI_H_
#define _DRV_SCI_H_

#include "system.h"

#define SCI_BUFFER_SIZE      ((UINT8)0xc8)/*% 200 , zui duo cun 138 BYTE in 10ms*/
//#define SCI_RX_FRAME_BUFFER_SIZE      ((UINT8)0xc8)/*% 200,  zui duo cun 138 BYTE in 10ms*/

/*****************************************************************************
**  typedef
*****************************************************************************/
//typedef enum
//{
//    DEBUG_STOP_MODE = 0,
//    DEBUG_WAVE_MODE,
//    DEBUG_FORCE_MODE,    
//}DEGUG_MODE_E;
    
/*
 * sci state
 */
typedef enum {
    SCI_SUCCESS = 0,
    SCI_ERROR,
    SCI_PARAM_ERROR,
    SCI_INIT_ERROR,
    SCI_TX_BUFFER_FULL,   
}SCI_STATE_E;

/*
 * sci bus state
 */
typedef enum{
    SCI_BUS_ERROR_ACTIVE = 0,
    SCI_BUS_ERROR_PASSIVE,
    SCI_BUS_BUSOFF,
}SCI_BUS_STATE_E;

/*****************************************************************************
**#include 
*****************************************************************************/
#pragma CODE_SEG __NEAR_SEG NON_BANKED 
 __interrupt void Comm_isr_SCI1(void);
#pragma CODE_SEG DEFAULT

void drv_sciInit(void);
void drv_sci1SendHandler(void);
UINT8 drv_sci1DataRxBuffer_full(void);//rx buff shi fou full
UINT8 drv_sci1DataTxBuffer_full(void);//Tx buff shi fou full
BOOL drv_sci1SendFrame(UINT8 id,BOOL sub_exist,UINT8 sub_id,UINT8 txData_len,UINT8* p_u8_txData);
void drv_sci1DataBuffer_push_itf(UINT8 u8_data);
UINT8 drv_sci1_u8_getRxMessageCount(void);
BOOL drv_sci1_v_getMessage(UINT8 *u8_id,UINT8 *u8_sub_id,UINT8 *u8_length,UINT8 *p_u8_txData);



/*****************************************************************************
** other
*****************************************************************************/


/****************************************************************************/

#endif	//_SCI_H_H_

/*****************************************************************************
** End File
*****************************************************************************/

